package com.leyou.upload.web;

import com.leyou.upload.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 *
 * @author: wangzibeng
 * Date: 2019/4/29 0029
 * Time: 10:55
 */

@RestController
public class UploadController {
    @Autowired
    private UploadService uploadService;

    @PostMapping("image")
    public ResponseEntity<String> uploadImg(@RequestParam("file") MultipartFile file) {
        return ResponseEntity.ok(uploadService.upLoadImg(file));
    }

    /**
     * 阿里云文件上传获取签名
     */
    @GetMapping("signature")
    public ResponseEntity<Map<String, Object>> getAliSignature() {
        return ResponseEntity.ok(uploadService.getAliSignature());
    }
}
